1. Technical Field
The present invention relates generally to multiprocessor (MP) computer systems and more particularly to the use Of collaborative "spinlocks" in a symmetric multiprocessor (SMP)-based operating system to prevent concurrent access to an operating system kernel extension such as a device driver.
2. Description of the Related Art
A device driver is a known operating system kernel extension. Most device drivers in use today in multiprocessor (MP) computer systems were written for uniprocessor operating systems rather than a symmetric multiprocessor-based operating system. Consequently, the writers of these drivers never envisioned a situation where two processors would request the services of the driver concurrently.
Such known device drivers include a "task time" component and an "interrupt time" component. The task time component is used to request services of a device managed by the device driver. The request typically completes asynchronously and, thereafter, the device driver is notified of such completion via external interrupt. Mutual exclusion to data structures shared by the task time component and the interrupt time component is typically provided by using the Intel CLI (disable interrupt) and STI (enable interrupt) instructions. In particular, issuing the CLI instruction prevents external interrupts, thus protecting the data structures from the interrupt time component.
The use of the Intel CLI instruction to provide mutual exclusion to data structures will not work in a MP environment, however. In particular, an Intel CLI instruction executed from one processor in the system will not disable interrupts on every processor; therefore, the interrupt time component may be executing on one processor while the task time processor is executing on another processor. Ultimately, the data structures will be corrupted.
One possible method to solve this problem would be to force execution of both the task time and interrupt time components of all device drivers to a single processor. Such an approach, in effect, would emulate the environment for which the device driver was originally designed. The performance of the MP system using this approach is quite unacceptable. Another approach would be to use a single "spinlock" to protect both the task time and interrupt component of the device driver. As is known in the art, a spinlock is a software mechanism involving a shared memory location having a set of known states that imply "ownership" (or the lack thereof) with respect to a given resource associated with the spinlock. A single spinlock has been used in an MP environment to provide external interrupt serialization, as described in U.S. Pat. No. 5,560,018 to Macon, Jr. et al., which patent is assigned to the assignee of this application. This approach, while satisfactory, does not provide optimal performance, in part because of the increased interrupt latency which is introduced while waiting for the device driver to release the single spinlock.
Understandably, authors of existing device driver code are not interested in rewriting the driver simply to adapt it to a multiprocessor operating system. Therefore, another means of allowing the efficient use of these existing device drivers must be developed. The present invention addresses this important problem.